package com.cf.module.app;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import com.cf.base.comm.widget.watermark.WatermarkUtils;
import com.cf.base.comm.widget.watermark.WatermarkView;
import com.cf.base.sp.SpCore;


/**
 * @author yangji
 */
public class BaseDialogFragment extends DialogFragment implements View.OnClickListener {

    private View mRootView;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        this.mRootView = inflater.inflate(R.layout.app_module_dialog, container, false);

        initView();

        return mRootView;
    }

    private void initView() {
        mRootView.findViewById(R.id.btnUpdateDialog).setOnClickListener(v -> {
            WatermarkView watermarkView = getDialog().getWindow().findViewById(R.id.comm_lib_watermark_view_id);
            watermarkView.setWatermarkText("更新弹窗" + System.currentTimeMillis());
        });

        //不可回收
        mRootView.findViewById(R.id.btnUpdate).setOnClickListener(v ->
                update()
        );

    }

    private void update() {
        WatermarkUtils.singleton.get().setWatermarkText("全局弹窗更新" + System.currentTimeMillis()).update();
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public void onClick(View v) {
        WatermarkUtils.singleton.get().setWatermarkText("全局弹窗更新" + System.currentTimeMillis()).update();
    }

    @Override
    public void onDestroyView() {

        super.onDestroyView();
    }
}
